//
//  DWViewController.m
//  DWDraggingView
//
//  Created by Devwan on 04/12/2017.
//  Copyright (c) 2017 Devwan. All rights reserved.
//

#import "DWViewController.h"

@interface DWViewController () <DWDraggingViewDelegate>
@property (nonatomic,strong) UILabel *labelTitle;
@end

@implementation DWViewController

# pragma mark - Lazy

- (UILabel *)labelTitle {
    if (!_labelTitle) {
        _labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, kSCREEN_WIDTH, 44)];
        _labelTitle.backgroundColor = [UIColor grayColor];
        _labelTitle.textColor = [UIColor yellowColor];
        _labelTitle.textAlignment = NSTextAlignmentCenter;
        [self.view addSubview:_labelTitle];
    }
    return _labelTitle;
}

# pragma mark - Life cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    DWDraggingView *darggingView = [[DWDraggingView alloc] init];
    darggingView.delegate = self;
    [self.view addSubview:darggingView];
    
    [self didTouchesMovedWithPosition:DWPositionTypeLeft];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

# pragma mark - <DWDraggingViewDelegate>

- (void)didTouchesMovedWithPosition:(DWPositionType)positionType {
    //    NSLog(@"%ld", positionType);
    
    if (positionType == DWPositionTypeLeft) {
        self.labelTitle.text = @"左边";
    } else if (positionType == DWPositionTypeMiddle) {
        self.labelTitle.text = @"中间";
    } else {
        self.labelTitle.text = @"右边";
    }
}


@end
